import 'package:erp/res/resources.dart';
import 'package:erp/widgets/load_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class SearchHeader extends StatelessWidget {
  final Function? onTapFilter;
  final Function(String text)? onTapSearch;

  final TextEditingController editingController = TextEditingController();

  SearchHeader({this.onTapFilter, this.onTapSearch});

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.transparent,
      height: 90.h,
      padding: EdgeInsets.symmetric(horizontal: 52.w),
      child: Row(
        children: [
          Container(
            height: 90.h,
            child: GestureDetector(
              behavior: HitTestBehavior.translucent,
              onTap: () {
                if (onTapFilter != null) {
                  onTapFilter!();
                }
              },
              child: Row(
                children: [
                  LoadAssetImage("filter", width: 22.w, height: 23.h),
                  SizedBox(width: 9.w),
                  Text(
                    "筛选",
                    style: TextStyle(color: Color(0xFF666666), fontSize: 24.sp),
                  ),
                  SizedBox(width: 20.w),
                ],
              ),
            ),
          ),
          Expanded(
            child: Container(
              decoration: BoxDecoration(
                border: Border.all(color: Color(0xFFCCCCCC), width: 2.w, style: BorderStyle.solid),
                borderRadius: BorderRadius.all(Radius.circular(25.r)),
              ),
              child: Row(
                children: [
                  SizedBox(width: 32.w),
                  Expanded(
                    child: TextField(
                      controller: editingController,
                      maxLines: 1,
                      textAlignVertical: TextAlignVertical.bottom,
                      decoration: InputDecoration(
                        isDense: true,
                        hintText: '请输入流程编号/名称/申请人',
                        hintStyle: TextStyle(
                          color: Color(0xFFCCCCCC),
                          fontSize: 24.sp,
                          fontWeight: FontWeight.w400,
                        ),
                        contentPadding: EdgeInsets.only(right: 32.w),
                        border: Styles.NONE_INPUT_BORDER,
                        enabledBorder: Styles.NONE_INPUT_BORDER,
                        focusedBorder: Styles.NONE_INPUT_BORDER,
                      ),
                    ),
                  ),
                  SizedBox(
                    width: 1.w,
                    height: 30.h,
                    child: DecoratedBox(decoration: BoxDecoration(color: Colours.TEXT_GRAY_C)),
                  ),
                  GestureDetector(
                    onTap: () {
                      if (onTapSearch != null) {
                        onTapSearch!(editingController.text);
                      }
                    },
                    child: Padding(
                      padding: EdgeInsets.only(left: 10.w, right: 20.w),
                      child: LoadAssetImage("search", width: 30.w, height: 30.h),
                    ),
                  ),
                ],
              ),
            ),
          )
        ],
      ),
    );
  }
}
